# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=soxr
pkgver=0.1.3
pkgrel=7
pkgdesc="High quality, one-dimensional sample-rate conversion library"
url="https://sourceforge.net/projects/soxr/"
arch="all"
license="LGPL-2.1-or-later"
makedepends="cmake samurai"
subpackages="$pkgname-doc $pkgname-static $pkgname-dev"
source="$pkgname-$pkgver.tar.xz::https://sourceforge.net/projects/soxr/files/soxr-$pkgver-Source.tar.xz/download"
builddir="$srcdir/$pkgname-$pkgver-Source"

build() {
	cmake -B build-static -G Ninja \
		-DCMAKE_INSTALL_PREFIX:PATH=/usr \
		-DBUILD_SHARED_LIBS=False \
		-DBUILD_TESTS=ON \
		-DCMAKE_BUILD_TYPE=None
	cmake --build build-static

	CFLAGS="$CFLAGS -flto=auto" \
	cmake -B build-shared -G Ninja \
		-DCMAKE_INSTALL_PREFIX:PATH=/usr \
		-DBUILD_SHARED_LIBS=True \
		-DBUILD_TESTS=ON \
		-DCMAKE_BUILD_TYPE=None
	cmake --build build-shared
}

check() {
	cd "$builddir"/build-static
	ninja test
	cd "$builddir"/build-shared
	ninja test
}

package() {
	DESTDIR="$pkgdir" cmake --install build-static
	DESTDIR="$pkgdir" cmake --install build-shared
}

doc() {
	amove usr/share
}

sha512sums="
f4883ed298d5650399283238aac3dbe78d605b988246bea51fa343d4a8ce5ce97c6e143f6c3f50a3ff81795d9c19e7a07217c586d4020f6ced102aceac46aaa8  soxr-0.1.3.tar.xz
"
